﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using MySql.Data.Types;



namespace SoftwareSearch
{
    public partial class SoftwareSearchForm : Form
    {
        public SoftwareSearchForm()
        {
            InitializeComponent();
        }

        private void connectButton_Click(object sender, EventArgs e)
        {
            string external = "Server=littleman.servebeer.com; Database=SoftwarePortal; UID=cp2011 ;Password=visual_studio";
            MySqlConnection myConnection = new MySqlConnection(external);
            try
            {
                myConnection.Open();
                string strSQLCommand = "SELECT * FROM Software";
                MySqlCommand myCommand = new MySqlCommand(strSQLCommand, myConnection);
                MySqlDataReader myReader = myCommand.ExecuteReader();
                
                try
                {
                  while(myReader.Read()) 
                  {
                      Console.WriteLine(myReader.GetString(0) + " - " + myReader.GetString(1) + " - " + myReader.GetString(2));
                  }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                } 


                myConnection.Close();
                MessageBox.Show("Done");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            } 

        }
    }
}
